import 'package:cream_chat_flutter/navigator/HiNavigator.dart';
import 'package:cream_chat_flutter/pages/IndexPage/IndexPage.dart';
import 'package:flutter/material.dart';
import 'package:cream_chat_flutter/globals/AProviders.dart';
import 'package:cream_chat_flutter/globals/ThemeProvider.dart';
import 'package:flutter/rendering.dart';
import 'package:provider/provider.dart';

void main() {
  // debugPaintSizeEnabled=true;
  runApp(CreamChatApp());
}

class CreamChatApp extends StatefulWidget {
  @override
  _CreamChatAppState createState() => _CreamChatAppState();
}

class _CreamChatAppState extends State<CreamChatApp> {
  final delegate = HiRouteDelegate(
    onGenerateRoute: (RouteSettings settings) => MaterialPageRoute(
    settings: settings,
    builder: (BuildContext context) {
      return Index();
    },
  ),
  );

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: providers,
      child: Consumer(
        builder:
            (BuildContext context, ThemeProvider themeProvider, Widget child) {
          return MaterialApp.router(
            title: '奶油聊天',
            theme: themeProvider.getTheme(),
            darkTheme: themeProvider.getTheme(isDarkMode: true),
            themeMode: themeProvider.getThemeMode(),
            routeInformationParser: HiRouteParser(),
            routerDelegate: delegate,
          );
        },
      ),
    );
  }
}

